In article <536@sdacs.ucsd.EDU> wade@sdacs.ucsd.EDU (Wade Blomgren) writes:
>
>What is the best (easiest) way to allow entry of a password on the screen
>while suppressing the display of the actual characters in the
>edittext item?
It actually isn't very difficult to intercept the key events and keep a hidden copy of the password string. It isn't necessary to remember any context since you have access to the TextEdit record, and it tells you what the current selection is. The following routine is a filter for a name/password dialog box. It displays bullets (ala AppleShare) and stores the real password in a global string, pwStr. It also handles hitting return or enter.
{ signonFilter -- dialog filter for doSignon, hides password }
FUNCTION signonFilter (dp : DialogPtr;
VAR theEvent : EventRecord;
VAR itemHit : integer) : boolean;
CONST
nameItem = 3;
passwordItem = 4;
bs = $08;
tab = $09;
cr = $0D;
enter = $03;
larrow = $1C;
rarrow = $1D;
uparrow = $1E;
downarrow = $1F;
VAR
dpeek : DialogPeek;
theChar : char;
theStr : Str255;
selStart, selEnd : integer;
h : Handle;
itemType : integer;
box : Rect;
BEGIN
signonFilter := false;
dpeek := DialogPeek(dp);
IF ((theEvent.what = keydown) OR (theEvent.what = autoKey)) THEN
Don't feel so bad Scott, you would have never been burned anyway. Page 413 of
Inside Mac has a warning stating:
"If either the dialog template resource or the item list cannot be read, the function result is undefined."
I have never gotten nil as a result from GetNewDialog. As far as I know, Apple hasn't bothered to fix the call yet. Paranoid programmers (like myself) put
envelope routines around GetNewDialog and Alert. The routine reads in both
the DITL and DLOG (or ALRT) resource and makes sure they're non-purgeable.
Then it calls GetNewDialog. Window centering code that observes the system 7 flags under systm 6 can be inserted here as well.
Anybody out there know why apple likes to make our lives just a bit more interesting by not retuning error codes for the above routines and being so wierd about
GetResource ? It really pisses me off.
Hat to ramble, but my newsposter won't allow me to type less than I quote.